<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  .headerStyle{
    background-color: antiquewhite;
  }
  h1{
    color: blueviolet;
  }
</style>
<body>
  <div class="headerStyle">
    <h1 style="text-align: center;" id="test">测试代码</h1>
  </div>
  <script>
    const evenFun =  document.getElementById('test')
    evenFun.onclick = function() {
      console.log(123)
    }
  </script>
</body>
</html>